package com.rrd.dw.mr.gzip.kafka;

import com.ucredit.babel.common.model.BaseModel;
import com.ucredit.babel.common.model.RecordType;
import com.ucredit.babel.common.model.blzcredit.BlzCreditHitListData;
import com.ucredit.babel.common.model.blzcredit.BlzCreditHitListRecord;
import com.ucredit.babel.common.model.blzcredit.BlzCreditHitListScore;
import com.ucredit.babel.common.model.xinyisou.XinYiSouBlankListData;
import com.ucredit.babel.common.model.xinyisou.XinYiSouBlankListRecord;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @Classname XinYiSouBlackListParse
 * @Description 信宜搜-黑名单 2021-05-12
 * @Date 2021/6/9 21:05
 * @Created by lzw
 */
public class XinYiSouBlackListParse extends ParseBase {
    Text key = new Text();
    Text value = new Text();

    @Override
    public boolean parseJob(Mapper.Context context, BaseModel<?> model, String successful) throws IOException, InterruptedException {
        XinYiSouBlankListRecord obj = (XinYiSouBlankListRecord) model;
        StringBuilder sb = getBaseInfo(obj, successful);

        XinYiSouBlankListData info = obj.getData();

        sb.append(info.getCode()).append(CRT001);
        sb.append(info.getMsg()).append(CRT001);
        sb.append(info.getRequestId()).append(CRT001);

        sb.append(info.getBlackList()).append(CRT001);

        key.set(getKey());
        value.set(sb.toString().replace("\n", " ").replace("\r", " "));
        context.write(key, value);


        return true;
    }

    @Override
    public String getTableName() {
        return "kafka_babel_xinyisou_blacklist_inc";
    }

    @Override
    public String getType() {
        return RecordType.XINYISOU_BLACKLIST_RECORD.toString();
    }

    @Override
    public String getComment() {
        return "信宜搜-黑名单";
    }
}
